package code.dao.impl;

import code.models.Phrase;

import org.springframework.stereotype.Repository;

import code.dao.IPhraseDAO;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
import javax.persistence.Query;


@Repository
public class PhraseDAO implements IPhraseDAO 
{
    private EntityManager entityManager;

    @PersistenceContext
    public void setEntityManager(EntityManager entityManager) 
    {
        this.entityManager = entityManager;
    }


    public List<Phrase> getAllPhrases() 
    {
    	Query query=entityManager.createQuery("from Phrase");
    	List<Phrase> result= query.getResultList();
       return result;
    }
}
